package com.zzyl.nursing.controller;

import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.NursingLevel;
import com.zzyl.nursing.service.INursingLevelService;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理等级控制器
 */
@Api(tags = "护理等级管理")
@RestController
@RequestMapping("/nursing/nursingLevel")
public class NursingLevelController extends BaseController {

    @Autowired
    private INursingLevelService nursingLevelService;

    @ApiOperation("查询所有护理等级")
    @GetMapping("/listAll")
    public AjaxResult listAll() {
        List<NursingLevel> list = nursingLevelService.listAll();
        return success(list);
    }

    @PreAuthorize("@ss.hasPermi('nursing:nursingLevel:list')")
    @ApiOperation("查询护理等级列表")
    @GetMapping("/list")
    public TableDataInfo<List<NursingLevel>> list(@ApiParam("护理等级查询条件") NursingLevel nursingLevel) {
        startPage();
        List<NursingLevelVo> list = nursingLevelService.selectNursingLevelList(nursingLevel);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('nursing:nursingLevel:query')")
    @ApiOperation("获取护理等级详细信息")
    @GetMapping(value = "/{id}")
    public R<NursingLevel> getInfo(@ApiParam("护理等级ID") @PathVariable("id") Long id) {
        NursingLevel nursingLevel = nursingLevelService.selectNursingLevelById(id);
        return R.ok(nursingLevel);
    }

    @PreAuthorize("@ss.hasPermi('nursing:nursingLevel:add')")
    @Log(title = "护理等级", businessType = BusinessType.INSERT)
    @ApiOperation("新增护理等级")
    @PostMapping
    public AjaxResult add(@ApiParam("护理等级对象") @RequestBody NursingLevel nursingLevel) {
        return toAjax(nursingLevelService.insertNursingLevel(nursingLevel));
    }

    @PreAuthorize("@ss.hasPermi('nursing:nursingLevel:edit')")
    @Log(title = "护理等级", businessType = BusinessType.UPDATE)
    @ApiOperation("修改护理等级")
    @PutMapping
    public AjaxResult edit(@ApiParam("护理等级对象") @RequestBody NursingLevel nursingLevel) {
        return toAjax(nursingLevelService.updateNursingLevel(nursingLevel));
    }

    @PreAuthorize("@ss.hasPermi('nursing:nursingLevel:remove')")
    @Log(title = "护理等级", businessType = BusinessType.DELETE)
    @ApiOperation("删除护理等级")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("护理等级ID数组") @PathVariable Long[] ids) {
        return toAjax(nursingLevelService.deleteNursingLevelByIds(ids));
    }
}